package router

import (
	jwt "gitee.com/sansaniot/ssiot-core/httpmvc/jwtauth"
	"github.com/gin-gonic/gin"
	"ssadmin/internal/admin/apis"
)

func init() {
	AuthRouters = append(AuthRouters, registerDictRouter)

}

func registerDictRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	dictApi := apis.SysDictType{}
	dataApi := apis.SysDictData{}
	dicts := v1.Group("/api/dict").Use(authMiddleware.MiddlewareFunc())
	{

		dicts.GET("/data/find", dataApi.GetPage)
		dicts.GET("/data/get/:dictCode", dataApi.Get)
		dicts.POST("/data/add", dataApi.Insert)
		dicts.POST("/data/modify", dataApi.Update)
		dicts.POST("/data/remove", dataApi.Delete)
		dicts.GET("/data/export", dataApi.ExportDictData)
		dicts.POST("/data/import", dataApi.ImportDictData)

		dicts.GET("/type-option-select", dictApi.GetAll)
		dicts.GET("/type/find", dictApi.GetPage)
		dicts.GET("/type/get:id", dictApi.Get)
		dicts.POST("/type/add", dictApi.Insert)
		dicts.POST("/type/modify", dictApi.Update)
		dicts.POST("/type/remove", dictApi.Delete)
		dicts.GET("/type/export", dictApi.ExportDictType)
		dicts.POST("/type/import", dictApi.ImportDictType)
	}
	opSelect := v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc())
	{
		opSelect.GET("/option-select", dataApi.GetAll)
	}
}
